import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from './router'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import ElementPlus, { ElMessage } from 'element-plus'
import 'element-plus/dist/index.css'
const app = createApp(App)
import axios from 'axios'
axios.defaults.baseURL="http://localhost:4567"

router.beforeEach((to, from, next) => {
    if (to.matched.some(record => record.meta.requireAuth)) {
        if (localStorage.getItem("user")) {
            next();
        }
        else {
            ElMessage.warning("请先登录")
            next({
                path: '/login',
            })
        }
    }
    else {
        next();
    }
});
app.use(ElementPlus)
app.use(router)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.mount('#app')